import {action, makeObservable, observable} from "mobx";

class Counter {
    constructor() {
        // 参数1：target 把谁变成响应式(可观察)；
        // 参数2：指定哪些属性或方法变成可观察
        makeObservable(this, {
            //--------------------url--------------------
            url: observable,
            setUrl: action.bound,
            getUrl: action,
            resetUrl: action,
            //--------------------title--------------------
            title: observable,
            setTitle: action.bound,
            getTitle: action,
            resetTitle: action,
            //--------------------path--------------------
            path: observable,
            setPath: action.bound,
            getPath: action,
            //--------------------height--------------------
            height: observable,
            setHeight: action,
            getHeight: action,
        })
    }

    /**
     * Url
     */
    url = ""

    setUrl(newUrl: string) {
        this.url = newUrl
    }

    getUrl() {
        return this.url
    }

    resetUrl() {
        this.url = ""
    }

    /**
     * Title
     */

    title = ""

    setTitle(newTitle: string) {
        this.title = newTitle
    }

    getTitle() {
        return this.title
    }

    resetTitle() {
        this.title = ""
    }

    /**
     * Path
     */
    path: string = ""

    setPath(newPath: string) {
        this.path = newPath
    }

    getPath() {
        return this.path
    }

    /**
     * Style的Height
     */

    height = 0

    setHeight(newHeight: number) {
        this.height = newHeight
    }

    getHeight() {
        return this.height
    }
}

export default new Counter();
